<template>
  <div class="cart">
    <!-- 顶部导航栏 -->
    <nav-bar class="nav-bar">
      <div slot="center">购物车({{ Length }})</div>
    </nav-bar>
    <!-- 列表展示 -->
    <cart-list></cart-list>
    <!-- 结算页面 -->
    <bottom-bar></bottom-bar>
  </div>
</template>

<script>
import NavBar from "components/common/navbar/NavBar";
import cartList from "views/cart/childComps/cartList.vue";
import BottomBar from "views/cart/childComps/cartBottomBar.vue";

// 直接将vuex的getters转化为计算属性
import { mapGetters } from "vuex";

export default {
  name: "Cart",
  components: {
    NavBar,
    cartList,
    BottomBar,
  },
  computed: {
    // 直接将vuex的getters转化为计算属性
    // 1.第一种数组写法直接命名使用
    // ...mapGetters(["cartLength"]),

    // 1.第一种数组写法重命名使用
    ...mapGetters({
      Length: "cartLength",
    }),
  },
};
</script>

<style scoped>
.cart {
  width: 100%;
  height: 100vh;
}

.nav-bar {
  background-color: var(--color-tint);
  color: #fff;
  position: fixed;
  right: 0;
  left: 0;
  top: 0;
  z-index: 9;
}

.cart-list {
  position: absolute;
  top: 44px;
  bottom: 49px;
  width: 100%;
}
</style>
